//
// Created by xuchao on 16-11-21.
//

#include <sstream>
#include "OkPgUrl.h"

using namespace OKPg;

using namespace std;

OkPgUrl::OkPgUrl(const string &dbName,
                 const string &user,
                 const string &password,
                 const string &host,
                 u_int port,
                 const string &protocol)
        : protocol_(protocol),
          host_(host),
          port_(port),
          dbName_(dbName),
          user_(user),
          password_(password) {

}

string OkPgUrl::toString() const {
    std::stringstream ss;
    ss << protocol_;
    ss << "://";
    ss << host_;
    ss << ":";
    ss << port_;
    ss << "/";
    ss << dbName_;
    ss << "?";
    ss << "user=";
    ss << user_;
    ss << "&password=";
    ss << password_;
    return ss.str();
}
